package com.test.groovy

/**
 * Ranger--GroovyTest
 *
 * @author: Jovi
 *
 * @createTime: 2018-06-11 13:48
 *
 * */
class Ranger {

    static void main(String[] args) {

        //showColl()

        //showColl1()

    }

    private static void showColl1() {
        def numbers = [1, 2, 3, 4]

        assert numbers + 5 == [1, 2, 3, 4, 5]

        assert numbers - [2, 3] == [1, 4]

        def numbers1 = [1, 2, 3, 4, 5]

        assert numbers1.join(",") == "1,2,3,4,5"

        assert numbers1.count(3) == 1

        assert ["JAVA", "GROOVY"] == ["Java", "Groovy"]*.toUpperCase()
    }

    private static void showColl() {
        def range = 0..4

        println(range)

        println range.class

        assert range instanceof List

        def coll = ["Groovy", "Java", "Ruby"]

        assert coll instanceof Collection

        assert coll instanceof ArrayList

        coll.add("Python")

        coll << "Smalltalk"

        coll[5] = "Perl"

        println coll

        assert coll[1] == "Java"
    }


}
